<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('消息管理列表')" />
</head>
<body class="gray-bg">
<form hidden class="form-horizontal m" id="form-message">
    <div class="form-group">
        <label class="col-sm-3 control-label">状态：</label>
        <div class="col-sm-8">
            <input name="status" class="form-control" type="text" th:value="no">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label">用户：</label>
        <div class="col-sm-8">
            <input name="receiveUserId" class="form-control" type="text" th:value="${receiveUserId}">
        </div>
    </div>
</form>
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('wstudy:message:edit')}]];
        var removeFlag = [[${@permission.hasPermi('wstudy:message:remove')}]];
        var prefix = ctx + "wstudy/message";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "消息管理",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: 'ID',
                    visible: false
                },
                {
                    field: 'createUserId',
                    title: '创建者ID',
                    visible: false
                },
                {
                    field: 'updateUserId',
                    title: '更新者ID',
                    visible: false
                },
                {
                    field: 'pubilshUserId',
                    title: '发布者ID',
                    visible: false
                },
                {
                    field: 'receiveUserId',
                    title: '接受人ID',
                    visible: false
                },
                {
                    field: 'isDelete',
                    title: '删除',
                    visible: false
                },
                {
                    field: 'status',
                    title: '状态',
                    formatter: function(value, row, index) {
                        if (value=='no'){
                            return "未读"
                        }else{
                            return "已读"
                        }
                    }
                },
                {
                    field: 'createTime',
                    title: '时间'
                },
                {
                    field: 'content',
                    title: '内容'
                },
                {
                    field: 'type',
                    title: '类型'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="updateMessage(\'' + row.id + '\')"><i class="fa fa-edit"></i>设为已读</a> ');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function updateMessage(id) {
            let url = prefix+"/setRead";
            let params = {
                "id":id,
                "status":"yes"
            }
            $.operate.post(url,params,function () {

            });
        }
    </script>
</body>
</html>